//
//  KASecurityCell.swift
//  kano
//
//  Created by Sophia on 2024/8/21.
//

import UIKit

class KASecurityCell: UITableViewCell {

    var BLOCK_block: ((String) -> Void)?
    
    lazy var var_cornerView: UIView = {
        let var_cornerView = UIView()
        var_cornerView.backgroundColor = .white
        var_cornerView.frame = CGRectMake(kscale(20), kscale(0), var_screenWidth-kscale(40), kscale(50))
        return var_cornerView
    }()
    lazy var var_titleLabel: UILabel = {
        let var_titleLabel = UILabel()
        var_titleLabel.font = UIFont.systemFont(ofSize: kscale(16), weight: .regular)
        var_titleLabel.textColor = .color8A8891
        var_titleLabel.text = ""
        return var_titleLabel
    }()
    
    lazy var var_arrowImg: UIImageView = {
        let var_arrowImg = UIImageView(image: UIImage(named: "mine_arrow"))
        var_arrowImg.size = CGSize(width: kscale(24), height: kscale(24))
        var_arrowImg.centerY = self.contentView.centerY
        var_arrowImg.right = var_cornerView.right-kscale(36)
        return var_arrowImg
    }()
    
    lazy var var_lineView: UIView = {
        let var_lineView = UIView()
        var_lineView.backgroundColor = .colorF4F4FD
        return var_lineView
    }()
    
    
    static func ka_cell(for tableView: UITableView) -> KASecurityCell {
        let var_identifityId = NSStringFromClass(self)
        var var_cell = tableView.dequeueReusableCell(withIdentifier: var_identifityId)
        if var_cell == nil {
            var_cell = KASecurityCell.init(style: .default, reuseIdentifier: var_identifityId)
        }
        return var_cell as! KASecurityCell
    }
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.ka_setUI()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func ka_setUI() {
        selectionStyle = .none

        contentView.backgroundColor = .colorf2f2f5
        contentView.addSubview(var_cornerView)
        var_cornerView.addSubview(var_titleLabel)
        var_cornerView.addSubview(var_arrowImg)
        var_cornerView.addSubview(var_lineView)
        
        var_titleLabel.snp.makeConstraints { make in
            make.centerY.equalTo(self.contentView)
            make.left.equalTo(kscale(16))
            make.right.equalTo(var_arrowImg.snp.left).offset(kscale(-8))
        }
        var_lineView.snp.makeConstraints { make in
            make.left.equalTo(kscale(16))
            make.right.equalTo(kscale(-16))
            make.height.equalTo(1)
            make.bottom.equalTo(-1)
        }
    }
}
